﻿<%@ Page Title="" Language="C#" AutoEventWireup="true" CodeBehind="WorkItem.aspx.cs" Inherits="HHMMS.UI.Modules.Workflow.WorkItem" Theme="" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>流程详细信息</title>
    <link href="~/App_Themes/default/style.css" type="text/css" rel="stylesheet" />
    <link href="~/App_Themes/default/Dialog.css" type="text/css" rel="stylesheet" />
    <link href="~/App_Themes/default/ItemDetail.css" type="text/css" rel="stylesheet" />
    <link href="~/Widgets/Validator/tipsy.css" type="text/css" rel="stylesheet" />
    <web:Script ID="Script1" src="~/Scripts/jquery.js" runat="server" />
    <web:Script ID="Script8" src="~/Modules/Workflow/Scripts/init.js" runat="server" />
    <web:Script ID="Script7" src="~/Scripts/jquery.utils.js" runat="server" />
    <web:Script ID="Script2" src="~/Widgets/Validator/jquery.tipsy.js" runat="server" />
    <web:Script ID="Script3" src="~/Widgets/Validator/jquery.validation.js" runat="server" />
    <web:Script ID="Script4" src="~/Widgets/Validator/jquery.validationConfig.js" runat="server" />
    <web:Script ID="Script6" src="~/Scripts/common.js" runat="server" />
    <web:Script ID="Script5" src="~/Scripts/lhgdialog/lhgdialog.js" runat="server" />
</head>
<body id="itemdetail" style="position: relative;">
    <script language="javascript" type="text/javascript">
        var Global = {};
        Global.contextPath = '<%=Util.ContextPath %>';
    </script>

    <form id="form1" runat="server">
    <asp:HiddenField ID="PartIds" runat="server" />
    <div id="dcontainer">
        <div id="dheader">
            <h1 style="font-size:16pt; font-weight:bold;">
                <asp:Label ID="lbAppName" runat="server" />
            </h1>
        </div>
        <!----------- 页面内容 ------------------>
        <div id="dcontent">
            <div class="toolbar">
                <ul>
                    <%if (this.ActionType == 0 || (this.workflowApi.CurrentWorkItem.WorkItemStatus < 2 && this.workflowApi.CurrentWorkItem.PartId == Bingosoft.Security.SecurityContext.User.Id ))
                      { %>
                    <li>
                        <!--保存-->
                        <asp:LinkButton runat="server" ID="LinkSave" key="Save" OnClientClick="return save();" OnCommand="ToolBarClick" EnableControl="(*.*)" InVisibleControl="(2.*)(*.传阅)"><span>保存</span></asp:LinkButton>
                    </li>
                    <li>
                        <!--发送-->
                        <asp:LinkButton runat="server" ID="LinkSend" key="Send" OnClientClick="return send();" OnCommand="ToolBarClick" EnableControl="(*.*)" InVisibleControl="(2.*)"><span>发送</span></asp:LinkButton>
                    </li>
                    <%} %>
                    <%if (this.workflowApi.CurrentActivity.IsStart == true && this.workflowApi.CurrentWorkItem.PartId == Bingosoft.Security.SecurityContext.User.Id)
                      { %>
                    <li>
                        <!--作废-->
                        <asp:LinkButton runat="server" ID="LinkDiscard" key="Discard" OnClientClick="return discard();" OnCommand="ToolBarClick" EnableControl="(*.*)" InVisibleControl="(2.*)"><span>作废</span></asp:LinkButton>
                    </li>
                    <%} %>
                    <li>
                        <!--关闭-->
                        <asp:LinkButton runat="server" ID="LinkClose" key="Close" OnClientClick="return closePage();" OnCommand="ToolBarClick" EnableControl="(*.*)" InVisibleControl="(2.*)"><span>关闭</span></asp:LinkButton>
                    </li>
                </ul>
            </div>
            <h2 style="display: none;">
                <asp:Label ID="lblTitle" runat="server"></asp:Label>
            </h2>
            <table cellspacing="0" cellpadding="0" width="100%" class="idt_tab">
                <tr style="cursor: pointer">
                    <td>
                        <img src="<%=Util.ContextPath %>/app_themes/default/idt_tle_icon1.gif" />
                        业务表单<a name="表单"></a>
                    </td>
                    <td align="right">
                        <img src="<%=Util.ContextPath %>/App_Themes/default/idt_tle_open.gif" />
                    </td>
                </tr>
            </table>
            <asp:PlaceHolder ID="phForm" runat="server"></asp:PlaceHolder>
            <%if (this.PartChoice.Items.Count > 1)
              { %>
            <table cellspacing="0" cellpadding="0" width="100%" class="idt_tab">
                <tr style="cursor: pointer">
                    <td>
                        <img src="<%=Util.ContextPath %>/app_themes/default/idt_tle_icon1.gif" />
                        审批意见<a name="表单"></a>
                    </td>
                    <td align="right">
                        <img src="<%=Util.ContextPath %>/App_Themes/default/idt_tle_open.gif" />
                    </td>
                </tr>
            </table>
            <table id="approve" cellspacing="0" cellpadding="5" width="100%" class="formitem" style="border:0;">
                <tr>
                    <th valign="top" style="width:120px; text-align:right;">
                        审批结果：<span style="color:Red;">*</span>
                    </th>
                    <td>
                        <asp:DropDownList ID="PartChoice" validator="required" runat="server">
                        </asp:DropDownList>
                    </td>
                </tr>
                <tr>
                    <th valign="top" style="width:120px; text-align:right;padding-top:8px;">
                        处理意见：<span style="color:Red;">*</span>
                    </th>
                    <td>
                        <asp:TextBox ID="PartComment" validator="required" TextMode="MultiLine" Rows="3" Width="310px" runat="server" style="overflow:auto;"></asp:TextBox>
                    </td>
                </tr>
            </table>
            <%} %>
            <table cellspacing="0" cellpadding="0" width="100%" class="idt_tab">
                <tr style="cursor: pointer">
                    <td>
                        <img src="<%=Util.ContextPath %>/app_themes/default/idt_tle_icon1.gif" />
                        审批历史<a name="表单"></a>
                    </td>
                    <td align="right">
                        <img src="<%=Util.ContextPath %>/App_Themes/default/idt_tle_open.gif" />
                    </td>
                </tr>
            </table>
            <web:SmartGridView ID="gridApprovalHistory" runat="server" AutoGenerateColumns="False"
                Width="100%" DataKeyNames="TaskID" DataSourceID="SmartDataSource1" PageSize="10">
                <Columns>   
                    <asp:BoundField DataField="TaskName" HeaderText="处理步骤" SortExpression="TaskName" ItemStyle-HorizontalAlign = "Center"  />
                    <asp:BoundField DataField="PartName" HeaderText="处理人信息" SortExpression="PartName" ItemStyle-HorizontalAlign = "Center"  />
                    <asp:BoundField DataField="PartComment" HeaderText="处理意见" SortExpression="PartComment" ItemStyle-HorizontalAlign = "Left"  />
                    <asp:BoundField DataField="FinishTime" HeaderText="处理时间" SortExpression="FinishTime" DataFormatString="{0:yyyy-MM-dd HH:mm}" ItemStyle-HorizontalAlign = "Center"  />
                </Columns>
                <PagerSettings />
                <EditRowStyle HorizontalAlign="Center" />
            </web:SmartGridView>
            <web:SmartSqlDataSource ID="SmartDataSource1" runat="server" SelectCommand="TodoTaskMag.ApprovalHistory.List" SelectCountCommand="TodoTaskMag.ApprovalHistory.List.Count"
                    DefaultSortExpression="TaskID DESC" SelectCommandAutoPageWrap="true">
            </web:SmartSqlDataSource>
        </div>
    </div>
    <script type="text/javascript" language="javascript">
        var workflowId = '<%=this.WorkflowId %>';
        var activityId = '<%=this.ActivityId %>';
        var activityName = '<%=this.workflowApi.CurrentActivity.ActivityName %>';
        var actionType = '<%=this.ActionType %>'

        $(document).ready(function () {
            $(document.forms[0]).validation();
        });

        function validateForm() {
            $(document.forms[0]).validation();
            if ($.validation.validate($(document.forms[0])).isError) {
                alert("请检查必填是否填写或格式是否正确!");
                return false;
            }
            return true;
        }

        function save(sender) {
            return validateForm();
        }

        function send(sender) {
            if (!validateForm()) {
                return false;
            }
            var data = {
                workflowId: workflowId,
                activityId: activityId,
                choice: $("select[id$='PartChoice']").val() || ''
            };
            $.dialog({
                title: '选择下一环节及处理人', lock: true, max: false, min: false, width: 500, height: 300, cancel: true,
                content: 'url:UserChoice.aspx?rnd=' + Math.random(),
                data: data,
                ok: function () {
                    var partIds = this.content.getData();
                    if (partIds === false) {
                        return false;
                    }
                    $("input[id$='PartIds']").val(partIds.join(','));
                    <%=Page.ClientScript.GetPostBackEventReference(this.LinkSend, null) %>;
                }
            });
            return false;
        }

        function discard(sender) {
            return confirm("确认作废吗？");
        }

        function closePage() {
            window.close();
            return false;
        }
    </script>
    </form>
</body>
</html>
